<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return['ischecklogin']=$this->model('member')->checklogin();
if($_RQ['op']=='get'){
	$basic=model('core/member')->basic($_SESSION['uid']);
	$item=pdo_get('jy_ad_team',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$mymember=pdo_get('jy_ad_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$item['level']=pdo_get('jy_ad_teamlevel',array('id'=>$item['level_id'],'uniacid'=>$_SESSION['uniacid']));
	$member=array_merge($basic,$item);
	$return['member']=$member;
	$teamids=$this->model('team')->getteamids($item['mid']);
	$mymember['teamnum']=count($teamids);
	if($teamids){
		$mymember['order_price']=pdo_getsum('jy_ad_fee_order',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$teamids),'order_price');
	}
	$mymember['getfee']=pdo_getsum('jy_ad_feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>array(0,1,2,3,4)),'fee');
	$mymember['getfee0']=pdo_getsum('jy_ad_feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>0),'fee');
	$mymember['getfee1']=pdo_getsum('jy_ad_feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>1),'fee');
	$mymember['getfee2']=pdo_getsum('jy_ad_feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>2),'fee');
	$mymember['getfee3']=pdo_getsum('jy_ad_feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>3),'fee');
	$mymember['getfee4']=pdo_getsum('jy_ad_feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>4),'fee');
	$mymember['isdui']=pdo_getsum('jy_ad_balance',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1),'money');
	$return['mymember']=$mymember;
	$teampage=$this->plugin_setting('teampage');
	$return['teampage']=$teampage;
	$return['params']['type']=$_RQ['type']?:2;
	set_html('title','我的团队');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>array(0,1,2,8));
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_ad_feelog',$params,array($pindex,$psize),$total,$fields,'',$orderby);	
	foreach($return['list'] as &$v){
			$v['member']=cfc('core')->member_show($v['mid']);
			$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
			$v['statustitle']=$this->commission_status[$v['status']];
			$v['typetitle']=$this->commission_money_types[$v['type']];
	}
	exi($return);
}
